from math import *

class Infix:
    def __init__(self, function):
        self.function = function
    def __ror__(self, other):
        return Infix(lambda x, self=self, other=other: self.function(other, x))
    def __or__(self, other):
        return self.function(other)
    def __rlshift__(self, other):
        return Infix(lambda x, self=self, other=other: self.function(other, x))
    def __rshift__(self, other):
        return self.function(other)
    def __call__(self, value1, value2):
        return self.function(value1, value2)


# Basic functional programming
id = lambda x:x  # The identity function
o = Infix(lambda f1, f2: lambda x: f1(f2(x)))  # Function composition: (f |o| g)(x) = f(g(x))
const = lambda x: lambda y: x # const(x) returns a function which always returns x
